/**
 * reply-actor
 * @authors 杨兴洲（of2502）
 * @date    2017/5/25 0025 20:23
 * @version 1.0
 * @last-modify  杨兴洲（of2502）
 */

import {Map, List} from 'immutable'
import {Action, Actor} from 'iflux2';
import * as types from '../constants/actionTypes'
export default class MenuActor extends Actor {
    defaultState() {
        return {
            isActive: true,
            button: List(),
            selectedIndex: -1,
            selectedSubIndex: -1
        }
    }

    @Action(types.FETCH_MENU)
    fetchMenu(state, data) {
        return state.set('button', data);
    }

    @Action(types.UPDATE_MENU)
    updateMenu(state, data) {
        return state.set('button', data);
    }

    @Action(types.DELETE_MENU)
    deleteMenu(state) {
        return state.set('button', List());
    }

    @Action(types.TOGGLE_MENU)
    toggleMenu(state, data) {
        return state.set('isActive', data);
    }

    @Action(types.SELECT_ITEM)
    selectItem(state, index) {
        return state.set('selectedIndex', index);
    }

    @Action(types.SELECT_SUB_ITEM)
    selectSubItem(state, index) {
        return state.set('selectedSubIndex', index);
    }
}